﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DcsGauges.Gui.Gauges.Interfaces;
using DcsGauges.Gui.Rendering;
using DcsGauges.DataStructures;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using DcsGauges.Shared.DataStructures;

namespace DcsGauges.Gui.Gauges.Concrete
{
    class EnginePanel : GuiRenderableBase, IComposedGauge
    {
        private EngineTemperatureGauge temperature          = null;
        public EngineTemperatureGauge TemperatureGauge
        {
            get { return this.temperature; }
        }

        private EngineRpmGauge rpmGauge                     = null;
        public EngineRpmGauge RpmGauge
        {
            get { return this.rpmGauge; }
        }

        private EnginePressureGauge pressureGauge           = null;
        public EnginePressureGauge PressureGauge
        {
            get { return this.pressureGauge; }
        }


        public EnginePanel(GuiRenderableBase parent, URect area, bool leftEngine) : base(parent, area)
        {
            if (leftEngine)
            {
                this.temperature                            = new EngineTemperatureGauge(this,  new URect(new ULoc(0.0f, 0.0f),  new USize(1.0f, 0.33f)), DcsProperties.Engines.Left.Temperature.Units, DcsProperties.Engines.Left.Temperature.Tenth);
                this.rpmGauge                               = new EngineRpmGauge(this,          new URect(new ULoc(0.0f, 0.33f), new USize( 1.0f, 0.33f)), DcsProperties.Engines.Left.CoreSpeed.Units, DcsProperties.Engines.Left.CoreSpeed.Tenth);
                this.pressureGauge                          = new EnginePressureGauge(this,     new URect(new ULoc(0.0f, 0.66f), new USize( 1.0f, 0.33f)), DcsProperties.Engines.Left.OilPressure);
            }                                                                                                                    
            else                                                                                                                 
            {                                                                                                                    
                this.temperature                            = new EngineTemperatureGauge(this,  new URect(new ULoc(0.0f, 0.0f),  new USize(1.0f, 0.33f)), DcsProperties.Engines.Right.Temperature.Units, DcsProperties.Engines.Right.Temperature.Tenth);
                this.rpmGauge                               = new EngineRpmGauge(this,          new URect(new ULoc(0.0f, 0.33f), new USize( 1.0f, 0.33f)), DcsProperties.Engines.Right.CoreSpeed.Units, DcsProperties.Engines.Right.CoreSpeed.Tenth);
                this.pressureGauge                          = new EnginePressureGauge(this,     new URect(new ULoc(0.0f, 0.66f), new USize( 1.0f, 0.33f)), DcsProperties.Engines.Right.OilPressure);
            }
        }

        public override void Render(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, GraphicsDevice device, Microsoft.Xna.Framework.Rectangle parentRect, float globalZIndex)
        {
            Rectangle rect = this.CalcViewportRect(parentRect);
            this.temperature.Render(spriteBatch, device, rect, globalZIndex);
            this.rpmGauge.Render(spriteBatch, device, rect, globalZIndex);
            this.pressureGauge.Render(spriteBatch, device, rect, globalZIndex);
        }
    }
}
